package com.anne.fish.model;

import com.anne.fish.model.BaseObject;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableComponent;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import javax.xml.bind.annotation.XmlRootElement;

import java.io.Serializable;

@Entity
@Table(name="search_word",catalog="fish")
@Searchable
@XmlRootElement
public class SearchWord extends BaseObject implements Serializable {
    private Long id;
    private Long searchDate;
    private String searchEngine;
    private String searchKeyword;

    @Id @GeneratedValue(strategy=IDENTITY) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="search_date", nullable=false)
    @SearchableProperty
    public Long getSearchDate() {
        return this.searchDate;
    }
    
    public void setSearchDate(Long searchDate) {
        this.searchDate = searchDate;
    }
    
    @Column(name="search_engine", nullable=false, length=20)
    @SearchableProperty
    public String getSearchEngine() {
        return this.searchEngine;
    }
    
    public void setSearchEngine(String searchEngine) {
        this.searchEngine = searchEngine;
    }
    
    @Column(name="search_keyword", nullable=false, length=90)
    @SearchableProperty
    public String getSearchKeyword() {
        return this.searchKeyword;
    }
    
    public void setSearchKeyword(String searchKeyword) {
        this.searchKeyword = searchKeyword;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SearchWord pojo = (SearchWord) o;

        if (searchDate != null ? !searchDate.equals(pojo.searchDate) : pojo.searchDate != null) return false;
        if (searchEngine != null ? !searchEngine.equals(pojo.searchEngine) : pojo.searchEngine != null) return false;
        if (searchKeyword != null ? !searchKeyword.equals(pojo.searchKeyword) : pojo.searchKeyword != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (searchDate != null ? searchDate.hashCode() : 0);
        result = 31 * result + (searchEngine != null ? searchEngine.hashCode() : 0);
        result = 31 * result + (searchKeyword != null ? searchKeyword.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("searchDate").append("='").append(getSearchDate()).append("', ");
        sb.append("searchEngine").append("='").append(getSearchEngine()).append("', ");
        sb.append("searchKeyword").append("='").append(getSearchKeyword()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
